<?php
class item_changeowntitle extends template_item
{
	var $default_name = "Change Your Own Title";
	var $default_description = "Use this item to change your own title";
	
	var $allow_multiple = 1;
	
	var $item_config = array();
	
	function public_use_form($inventory_ids = array())
	{
		$this->ipsclass->load_language('lang_market_items');
		
		$hidden_fields = $this->_get_hidden_fields($inventory_ids);
		
		return <<<EOF
<div class='formsubtitle'>{$this->ipsclass->lang['change_own_title']}</div>
<form action='{$this->base_url}' method='post'>
{$hidden_fields}
	<table class='ipbtable' cellspacing='0' cellpadding='0'>
		<tr>
			<td class='row1' align='left'>
				<b>{$this->ipsclass->lang['change_own_title_to']}</b>
			</td>
			<td class='row2' align='right'>
				<input type='input' name='member_title' value='{$this->ipsclass->member['title']}' size='30' class='forminput' />
			</td>
		</tr>
		<tr>
			<td class='darkrow1' align='center' colspan='2'>
				<input type='submit' name='item_used' value='{$this->ipsclass->lang['save_info']}' class='forminput' />
			</td>
		</tr>
	</table>
</form>
EOF;
	}
	
	function input_done()
	{
		return isset($this->ipsclass->input['member_title']) && isset($this->ipsclass->input['item_used']);
	}
	
	function public_use_item($inventory_ids = array()) 
	{
		$this->ipsclass->load_language('lang_market_items');
		
		$this->ipsclass->input['member_title'] = $this->ipsclass->parser->bad_words($this->ipsclass->input['member_title']);
		
		$this->ipsclass->DB->force_data_type = array( 'title' => 'string' );
		$this->ipsclass->DB->do_update('members',array(
														'title' => $this->ipsclass->input['member_title']
				),"id=".$this->ipsclass->member['id']);
		
		$this->delete_items($inventory_ids);
		
		$inv_id = reset($inventory_ids);
		$this->_write_log($inv_id, "Changed member title to {$this->ipsclass->input['member_title']}");
		
		$this->ipsclass->market_class->redirect('member_title_changed');
	}
}
?>